package top.misspro.valheimadminsocket.server;

import lombok.Getter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author liulinbo
 */
public class ServerContains {

    private final static ThreadLocal<String> THREAD_LOCAL = new InheritableThreadLocal<>();

    /**
     * 服务器端口
     */
    public static final int PORT = 8090;

    /**
     * 客户端列表
     */
    public static final Map<String, Client> CLIENT_MAP = new ConcurrentHashMap<>();

    public static Client getClient(String channelId) {
        return CLIENT_MAP.get(channelId);
    }

    /**
     * 服务器连接状态
     */
    @Getter
    public enum ServerStatus {
        /**
         * 已连接
         */
        CONNECTED,
        /**
         * 未连接
         */
        UN_CONNECT
    }

    public static String getThreadLocal() {
        return THREAD_LOCAL.get();
    }

    public static void setThreadLocal(String value) {
        THREAD_LOCAL.set(value);
    }

    public static void remove() {
        THREAD_LOCAL.remove();
    }

    public static Map<String, Client> getClientMap() {
        return CLIENT_MAP;
    }
}
